<!--  -->
<template>
  <div >
    <div class="nav bg-theme color-f text-l">
      <div style="display:flex;flex:2;">
          <!-- 返回按钮 -->
          <i class="iconfont icon-fanhui font19 pl08 iback" @click="goBack"></i>
          <!-- 标题 -->
          <span class="font19 ml16">
              {{ bartitle }}
          </span>
      </div>
      <!-- 起草 -->
      <span v-if='hasSaveIcon' @click="tosave()" style="margin-right:10px;margin-left:10px" class="font14">
          保存
      </span>
    </div>
    <div class="font15 pt50 pl10">
      <span class="titletext ">{{ pagename }}</span>
      <div class="graytext  mt10 font13">
        <span >发起人：</span>
        <span class="titletext">{{fromdetal.disName}}</span>
      </div>
    </div>
    <div class="font11 mt10 bggray ptandpb10">
      <div class=" graytext pl10">
          <span >发起人组织：</span>
          <span class="titletext">{{fromdetal.belongOrgName}}</span>
      </div>
      <div class="mt10 graytext pl10">
        <span >发起人联系方式：</span>
        <span class="titletext">{{fromdetal.tel}}</span>
      </div>
    </div>
    <van-form @submit="onSubmit">
      <van-field v-if="isdrawType==true" rows="1" autosize type="textarea" v-model="fromdetal.title" required label-width="4.5em" label="任务标题:" placeholder="请填写任务标题" :right-icon="isdrawType==true?'arrow':''" maxlength="1000" :rules="[{ required: true, message: '' }]" name="title" />
      <van-field required readonly :right-icon="isdrawType==true?'arrow':''" input-align="left" label-width="4.5em" clickable name="endTime" :value="fromdetal.endTime" label="截止时间:" placeholder="请选择截止时间"
        @click="showTimePicker = isdrawType==true?true:false" :rules="[{ required: true, message: '' }]"/>
      <van-popup v-model="showTimePicker" position="bottom">
        <van-datetime-picker :formatter='formatter' v-model="nowDate" type="date" :min-date="minDate" :max-date="maxDate"
          @cancel="showTimePicker = false" @confirm="showTimePickeronConfirm"/>
      </van-popup>
      <van-field required readonly :right-icon="isdrawType==true?'arrow':''" input-align="left" label-width="4.5em" clickable name="type" :value="fromdetal.type" label="业务类型:" placeholder="请选择业务类型" @click="isdrawType==true?showTypePickerDialog():''" :rules="[{required: true, message: ''}]"/>
      <van-popup v-model="showTypePicker" position="bottom">
        <van-picker show-toolbar 
            :columns="showTypecolumns"
            @confirm="showTypePickeronConfirm"
            @cancel="showTypePicker = false"
        />
      </van-popup> 
      <van-field required readonly :right-icon="isdrawType==true?'arrow':''" input-align="left" label-width="4.5em" clickable  :value="showOrgName" label="派往组织:" placeholder="请选择派往组织" @click="isdrawType==true?showOrgPickerDialog():''" :rules="[{required: true, message: ''}]"/>
      <van-popup v-model="showOrgPicker" position="bottom" style="height:40%">
        <div style="position:fixed;left:0;right:0">
          <div class="van-picker__toolbar">
            <van-button type="primary" native-type="button" class="van-picker__cancel" @click="checkcancel()">取消</van-button>
            <div style="flex:1"></div>
            <van-button type="info" native-type="button" class="van-picker__confirm" @click="checkconfirm()">确认</van-button>
          </div>
        </div>
        <van-checkbox-group v-model="resultList" @change="onChange">
          <div style="margin-top:50px">
            <van-checkbox v-for="(item,index) in orgList" :key="index" :name="item" style="padding-left:25%" class="mt5">
              <div style="display: flex;"><span class="font14">{{ item.orgName }}</span></div>
            </van-checkbox>
          </div>
        </van-checkbox-group>
      </van-popup> 
      <van-field v-if="infoTypeCode=='1'||infoTypeCode=='2'" required label-width="10.5em" readonly label="是否需要党办主任审核:"/>
      <van-field v-if="infoTypeCode=='3'" required label-width="10.5em" readonly label="是否需要支部书记审核:"/>
      <van-radio-group v-model="radio" direction="horizontal" :disabled="isdrawType!=true" style="margin-left:30px">
        <van-radio name="1"><span class="font14">是</span></van-radio>
        <van-radio name="2"><span class="font14">否</span></van-radio>
      </van-radio-group>
      <van-field rows="1" autosize type="textarea" v-model="fromdetal.description" required label-width="4.5em" :readonly="isdrawType!=true" label="任务描述:" placeholder="请填写任务描述" :right-icon="isdrawType==true?'arrow':''" maxlength="1000" :rules="[{ required: true, message: '' }]" name="description" />
      <div class="border-b-1">
        <van-field label-width="10em" readonly label="任务派发附件:" class="lyy-width" input-align="left" placeholder=""></van-field>
          <template >
              <template v-if="file_is_show1">
                <div v-for="(item,index) in fromdetal.fileList" :key="index" class="fileBox">
                  <div :readonly="isdrawType!=true" class="font14 fileLink" style="color:#0F85CF">
                        <a target="_blank" @click="openFileUrlfun(item.anonymousFilePath)">{{item.fileName}}</a>
                  </div>
                  <span class="font12 color-red ml5" v-if='isdrawType==true' @click="uploadFileDelete1(index)">X</span>
                </div>
              </template>
              <form v-if='isdrawType==true' action="" class="font14 file" style="height:46px;text-align:right;padding-right:20px">
                <van-uploader v-model="fileList1" :after-read="fileUpload"  :preview-image='false'>
                  <van-button icon="plus" type="primary" color="#60a9ec">上传文件</van-button>
                </van-uploader>
              </form>
          </template>
      </div>
      
      <van-field v-if="isdrawType!=true" rows="1" autosize type="textarea" v-model="fromdetal.submitText" required label-width="4.5em" :readonly="todotype!=true" label="填报内容:" placeholder="请填写填报内容" :right-icon="todotype==true?'arrow':''" maxlength="1000" :rules="[{ required: true, message: '' }]" name="submitText" />
      <div v-if="isdrawType!=true" class="border-b-1">
        <van-field label-width="10em" readonly label="填报附件:" class="lyy-width" input-align="left" placeholder=""></van-field>
          <template >
              <template v-if="file_is_show2">
                <div v-for="(item,index) in fromdetal.submitFileList" :key="index" class="fileBox">
                  <div :readonly="todotype!=true" class="font14 fileLink" style="color:#0F85CF">
                        <a target="_blank" @click="openFileUrlfun(item.anonymousFilePath)">{{item.fileName}}</a>
                  </div>
                  <span class="font12 color-red ml5" v-if='todotype==true' @click="uploadFileDelete2(index)">X</span>
                </div>
              </template>
              <form v-if='todotype==true' action="" class="font14 file" style="height:46px;text-align:right;padding-right:20px">
                <van-uploader v-model="fileList2" :after-read="fileUpload2"  :preview-image='false'>
                  <van-button icon="plus" type="primary" color="#60a9ec">上传文件</van-button>
                </van-uploader>
              </form>
          </template>
      </div>
      <div style="height:50px"></div>
      <div v-show="isdrawType==true||todotype==true" class="footer">
            <van-button  block  type="info" native-type="submit">流转下一步</van-button>
      </div>
      </van-form>
 </div>
</template>

<script>
import {findAllNoPage,findPOrgAndCityOrg,djzsUploadProcessFiles,saveDraft,findById,distribute,submitOrder,submitInfo,findCityDeapartmentAndCountyCompany} from "@/api/zsapi";
import {mapGetters} from "vuex"
import { Notify, Toast } from 'vant'
import moment from 'moment'
import {openFileUrl} from '@/store/openFile'
import { Dialog } from 'vant';
// import moaBridge_ha_djfupt from "@/assets/js/moaBridge_ha_djfupt";
  export default {
    components: {
       
    },
    data(){
            return{
              isdrawType:true,
              fromdetal:{},
              params:this.$route.query,
              minDate: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()),
              maxDate: new Date(new Date().getFullYear()+60,new Date().getMonth(),new Date().getDate()),
              nowDate: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()),
              showTimePicker:false,
              showTypePicker:false,
              showTypecolumns:[],
              typeList:[],
              showOrgPicker:false,
              orgList:[],
              todotype:false,
              file_is_show1:true,
              file_is_show2:true,
              fileList1:[],
              fileList2:[],
              hasSaveIcon:false,
              radio: '',
              resultList:[],
              showOrgName:'',
              pagename:'',
              getOrgType:'0',
              bartitle:'任务派发',
              infoTypeCode:'1'
            }
    },
    computed:{
        ...mapGetters(['user']),
        ...mapGetters(['userinfo'])
    },
    //生命周期--创建完成
    created() {
          console.log("是否为起草22222"+this.params.disType);
       if(this.params.todoType=='1'){
          this.todotype=true;
        }else{
          this.todotype=false;
        }
        if(this.params.isdraw=='1'){
          this.isdrawType=true;
          this.hasSaveIcon=true;
          this.getOrgType=this.params.getOrgType
          if(this.params.disType=='1'){
            this.bartitle='省公司任务派发工单'
            this.infoTypeCode="1"
          }else if(this.params.disType=='2'){
            this.bartitle='分公司任务派发工单'
            this.infoTypeCode="2"
          }else if(this.params.disType=='3'){
            this.bartitle='公司本部任务派发工单'
            this.infoTypeCode="3"
          }
        }else{
          this.isdrawType=false;
          this.hasSaveIcon=false;
        }
        if (this.isdrawType==true&&this.params.todoType!='3'){
          this.pagename=this.bartitle+'-起草' 
          this.fromdetal.disName=this.userinfo.truename;
          this.fromdetal.tel=this.userinfo.preferredMobile;
          this.fromdetal.isDb='1';
          this.fromdetal.id='';
          this.fromdetal.disType=this.params.disType;
          this.fromdetal.orderUuid='';
          this.fromdetal.submitText='';
          this.fromdetal.submitUserName='';
          this.fromdetal.submitFileList=[];  
          this.fromdetal.belongOrgName=this.userinfo.authOrgs[0].displayName;
         }else if (this.isdrawType==true&&this.params.todoType=='3'){
          this.getdetail();
         }else if (this.isdrawType==false){
          this.getdetail();
         }
    },
    activated() {
       
    },
    //生命周期--挂载完成
    mounted() {

    },
    //方法调用
    methods: {
      goBack() {
        if(this.$route.query.fromMoa&&this.moaBridge_ha_djfupt){
          this.moaBridge_ha_djfupt.closeDoc({refresh:true,appcode:'djfupt'});
        }else{
          this.$router.back(-1); //返回上一页
        }
      },
      openFileUrlfun(value){
            this.$router.push(
                {
                 name:'fileview',
                 query:{
                     openFileUrl: openFileUrl(value)
                    }
                }
            );
        },
       formatter(type, val) {
            if (type === 'year') {
              return `${val}年`;
            } else if (type === 'month') {
              return `${val}月`;
            } else if (type === 'day') {
              return `${val}日`;
            } else if (type === 'hour') {
              return `${val}时`;
            } else if (type === 'minute') {
              return `${val}分`;
            }
            return val;
          },
        getdetail(){
            if(this.isdrawType==true){
               console.log('统一待办进入xxxxxx'+this.params.fromMoa)
              distribute(Object.assign(this.params,{userName:this.user.userName}))
                .then((result)=>{
                    this.fromdetal={};
                    Toast.clear();
                    if(!result.data){
                        Notify(result.message);
                        return;
                    }
                    if(result.data.data){
                        this.fromdetal=result.data.data;
                        if(!result.data.data.fileList){
                            this.fromdetal.fileList=[];
                        }
                        this.pagename=this.fromdetal.title
                        if(this.fromdetal.disCompany&&this.fromdetal.disOrg){
                          this.showOrgName=this.fromdetal.disOrg+','+this.fromdetal.disCompany
                        }else if(this.fromdetal.disCompany){
                          this.showOrgName=this.fromdetal.disCompany
                        }else if(this.fromdetal.disOrg){
                          this.showOrgName=this.fromdetal.disOrg
                        }else {
                          this.showOrgName=''
                        }
                        if(this.fromdetal.isDb=='1'){
                          this.radio='1'
                        }else{
                          this.radio='2'
                        }
                        if(this.fromdetal.disType=='1'){
                          this.bartitle='省公司任务派发工单'
                          this.infoTypeCode="1"
                        }else if(this.fromdetal.disType=='2'){
                          this.bartitle='分公司任务派发工单'
                          this.infoTypeCode="2"
                        }else if(this.fromdetal.disType=='3'){
                          this.bartitle='公司本部任务派发工单'
                          this.infoTypeCode="3"
                        }
                    }
                })
            }else {
              // console.log('统一待办进入444444444'+this.moaBridge_ha_djfupt.closeDoc())
              // console.log('统一待办进入111111'+this.params.fromMoa)
                            console.log(this.params)

              // console.log('统一待办进入222222'+this.params.idcode.fromMoa)
              findById(Object.assign(this.params,{userName:this.user.userName}))
                .then((result)=>{
                    this.fromdetal={};
                    Toast.clear();
                    if(!result.data){
                        Notify(result.message);
                        return;
                    }
                    if(result.data.data){
                        this.fromdetal=result.data.data;
                        if(!result.data.data.fileList){
                            this.fromdetal.fileList=[];
                        }
                        this.pagename=this.fromdetal.title
                        this.fromdetal.belongOrgName=this.fromdetal.disPersonBelongOrg
                        this.showOrgName=this.fromdetal.belongOrg
                        if(this.fromdetal.isDb=='1'){
                          this.radio='1'
                        }else{
                          this.radio='2'
                        }
                        if(this.fromdetal.disType=='1'){
                          this.bartitle='省公司任务派发工单'
                          this.infoTypeCode="1"
                        }else if(this.fromdetal.disType=='2'){
                          this.bartitle='分公司任务派发工单'
                          this.infoTypeCode="2"
                        }else if(this.fromdetal.disType=='3'){
                          this.bartitle='公司本部任务派发工单'
                          this.infoTypeCode="3"
                        }
                    }
                })
            }
            
        },
        showTimePickeronConfirm(value){
            this.fromdetal.endTime=moment(value).format('YYYY-MM-DD');
            this.showTimePicker=false;
        },
        showTypePickerDialog(){
          console.log('选择类型1111111111111')
          findAllNoPage(Object.assign({userName:this.user.userName}))
            .then((res)=>{
              if(!res.data){
                Notify(res.message);
                return;
              }
              this.showTypecolumns=[];
              this.typeList=[];
              for(var i=0;i<res.data.data.length;i++){
                this.showTypecolumns.push(res.data.data[i].workTypeName);
              }
              this.typeList=res.data.data;
              this.showTypePicker=true;
              
            })
            .catch((error) => {
                Notify({ type: 'warning', message: '获取数据失败,请稍后重试' })
            });
        },
        showTypePickeronConfirm(value,index){
          this.fromdetal.type=value;
          this.showTypePicker=false;
        },
        showOrgPickerDialog(){
          this.resultList=[];
          if(this.params.getOrgType=='1'){
            findPOrgAndCityOrg(Object.assign({userName:this.user.userName}))
            .then((res)=>{
              if(!res.data){
                Notify(res.message);
                return;
              }
              this.orgList=[];
              // this.orgList=res.data.data;
              var parentOrgCode=res.data.data[0].orgCode
              console.log("parentOrgCode1111111"+parentOrgCode)
              for(var a=1;a<res.data.data.length;a++){
                 console.log("parentOrgCode"+res.data.data[a].parentOrgCode)
                if(res.data.data[a].parentOrgCode==parentOrgCode&&res.data.data[a].corpId&&res.data.data[a].erpId){
                  this.orgList.push(res.data.data[a])
                }
              }
              this.showOrgPicker=true;
              
            })
            .catch((error) => {
                Notify({ type: 'warning', message: '获取数据失败,请稍后重试' })
            });  
          }else{
            findCityDeapartmentAndCountyCompany(Object.assign({userName:this.user.userName}))
            .then((res)=>{
              if(!res.data){
                Notify(res.message);
                return;
              }
              this.orgList=[];
              this.orgList=res.data.data.slice(1);
              // var parentOrgCode=res.data.data[0].orgCode
              // console.log("parentOrgCode1111111"+parentOrgCode)
              // for(var a=1;a<res.data.data.length;a++){
              //    console.log("parentOrgCode"+res.data.data[a].parentOrgCode)
              //   if(res.data.data[a].parentOrgCode==parentOrgCode&&res.data.data[a].corpId&&res.data.data[a].erpId){
              //     this.orgList.push(res.data.data[a])
              //   }
              // }
              this.showOrgPicker=true;
              
            })
            .catch((error) => {
                Notify({ type: 'warning', message: '获取数据失败,请稍后重试' })
            }); 
            
          }
          
        },
        onChange() {
          console.log(this.resultList)
        },
        checkcancel(){
          this.resultList=[];
          this.showOrgPicker=false;
          this.zcxjDialogOrgCode=this.orgList[index].value;
        },
        checkconfirm(){
          var arr1 =[];//部门 
          var arr2 = [] //公司
          var names3 = [], codes3 = [];
          for(var q in this.resultList){
            names3.push(this.resultList[q].orgName);
            codes3.push(this.resultList[q].orgCode);
            if(this.resultList[q].companyTypeDictValue=='01' && this.resultList[q].levelDictValue=='2'){ //省公司部门
                arr1.push(this.resultList[q])
            }
            if(this.resultList[q].companyTypeDictValue=='02' && this.resultList[q].levelDictValue=='2'){ //分公司
                arr2.push(this.resultList[q])
            }
            if(this.resultList[q].companyTypeDictValue=='03' && this.resultList[q].levelDictValue=='3'){ //县部门
                arr2.push(this.resultList[q])
            }
          }
          this.showOrgName=names3.join(",");
          this.fromdetal.disOrgss=names3.join(",");
          //部门
          var names = [], codes = [];
          for (var i in arr1) {
                  names.push(arr1[i].orgName);
                  codes.push(arr1[i].orgCode);
          }
          this.fromdetal.disOrg=names.join(",");
          this.fromdetal.disOrgCode=codes.join(",");
          //公司
          var names2 = [], codes2 = [];
          for (var i in arr2) {
                  names2.push(arr2[i].orgName);
                  codes2.push(arr2[i].orgCode);
          }
          this.fromdetal.disCompany=names2.join(",");
          this.fromdetal.disCompanyCode=codes2.join(",");
          
          this.fromdetal.disType=this.infoTypeCode;
          this.fromdetal.workId="";
          this.fromdetal.isDb="";
          this.fromdetal.isShenhe="否";
          console.log('values'+JSON.stringify(this.fromdetal))
          this.showOrgPicker=false;
        },
        tosave(){
          if(this.radio=='1'){
            this.fromdetal.isDb='1'
          }else if(this.radio=='2'){
            this.fromdetal.isDb='0'
          }
          console.log('values'+JSON.stringify(this.fromdetal))
          saveDraft(Object.assign({userName:this.user.userName},{fromdetal:this.fromdetal}))
            .then((res)=>{
              if(!res.data||!res.data.data){
                Notify(res.message);
                return;
              }
              Notify('保存成功')
              this.$router.back(-1); //返回上一页
            })
            .catch((error) => {
                Notify({ type: 'warning', message: '保存失败,请稍后重试' })
            });
          
        },
        onSubmit(values){
          if(this.radio=='1'){
            this.fromdetal.isDb='1'
          }else if(this.radio=='2'){
            this.fromdetal.isDb='0'
          }

          if(this.fromdetal.fileList&&this.fromdetal.fileList.length&&this.fromdetal.fileList.length>0){
            var filedids=''
            for(var i=0;i<this.fromdetal.fileList.length;i++){
              if(i==0){
                filedids=this.fromdetal.fileList[i].id
              }else {
                filedids=filedids+','+this.fromdetal.fileList[i].id
              }
            } 
            this.fromdetal.fileIds=filedids;
          }
          if(this.fromdetal.submitFileList&&this.fromdetal.submitFileList.length&&this.fromdetal.submitFileList.length>0){
            var submitFileIdsss=''
            for(var i=0;i<this.fromdetal.submitFileList.length;i++){
              if(i==0){
                submitFileIdsss=this.fromdetal.submitFileList[i].id
              }else {
                submitFileIdsss=submitFileIdsss+','+this.fromdetal.submitFileList[i].id
              }
            } 
            this.fromdetal.submitFileIds=submitFileIdsss;
          }
          this.fromdetal.isSubmit='1'
          console.log('values'+JSON.stringify(this.fromdetal))
          if(this.todotype==true&&this.isdrawType!=true){
            var messageValue='请确认党办主任是否已通过审核！点击确认信息将上传到系统'
            if(this.infoTypeCode=='3'){
              messageValue='请确认支部书记是否已通过审核！点击确认信息将上传到系统'
            }
            if(this.fromdetal.isDb=='1'){
              Dialog.confirm({
                title: '',
                message: messageValue,
              })
              .then(() => {
                // on confirm  
                console.log('111111111111111111')
                submitInfo((Object.assign({userName:this.user.userName},{fromdetal:this.fromdetal})))
                .then((res)=>{
                  if(!res.data){
                    Notify(res.message);
                    return;
                  }else if(res.data.errcode==0){
                    console.log('统一待办进入444444444'+this.moaBridge_ha_djfupt)
                    if (this.params.fromMoa) {
                       console.log('统一待办进入5555555'+this.params.fromMoa)
                      this.moaBridge_ha_djfupt.closeDoc({
                        refresh: true,
                        appcode: "djfupt",
                      });
                    } else {
                      Notify({ type: 'success', message: '提交成功' })
                      this.$router.back(-1); 
                    }
                  }else{
                    Notify(res.message);
                    return;
                  }
                })
                .catch((error) => {
                  console.log('22222222222222222')
                    Notify({ type: 'warning', message: '提交失败,请稍后重试' })
                });
                })
              .catch(() => {
                  // on cancel
              });
            }else{
              if(this.fromdetal.fileList&&this.fromdetal.fileList.length&&this.fromdetal.fileList.length>0){
                var filedids=''
                for(var i=0;i<this.fromdetal.fileList.length;i++){
                  if(i==0){
                    filedids=this.fromdetal.fileList[i].id
                  }else {
                    filedids=filedids+','+this.fromdetal.fileList[i].id
                  }
                } 
                this.fromdetal.fileIds=filedids;
              }
              submitInfo((Object.assign({userName:this.user.userName},{fromdetal:this.fromdetal})))
                .then((res)=>{
                   console.log('res.data.errcode'+res.data.errcode)
                  if(!res.data){
                    Notify(res.message);
                    return;
                  }else if(res.data.errcode==0){
                    Notify({ type: 'success', message: '提交成功' })
                    this.$router.back(-1); //返回上一页
                  }else{
                    Notify(res.message);
                    return;
                  }
                })
                .catch((error) => {
                  console.log('22222222222222222')
                    Notify({ type: 'warning', message: '提交失败,请稍后重试' })
                });
            }
          }else{
            if(this.fromdetal.fileList&&this.fromdetal.fileList.length&&this.fromdetal.fileList.length>0){
            var filedids=''
            for(var i=0;i<this.fromdetal.fileList.length;i++){
              if(i==0){
                filedids=this.fromdetal.fileList[i].id
              }else {
                filedids=filedids+','+this.fromdetal.fileList[i].id
              }
            } 
            this.fromdetal.fileIds=filedids;
          }
            submitOrder((Object.assign({userName:this.user.userName},{fromdetal:this.fromdetal})))
            .then((res)=>{
              if(!res.data){
                Notify(res.message);
                return;
              }
              Notify({ type: 'success', message: '提交成功' })
                    this.$router.back(-1); //返回上一页
            })
            .catch((error) => {
                Notify({ type: 'warning', message: '提交失败,请稍后重试' })
            });
          }
        
        },
         fileUpload(file,detail){
            console.log('111'+JSON.stringify(file))
            let dataurl=file.content;
            let arr = dataurl.split(','),
            mime = arr[0].match(/:(.*?);/)[1],
            bstr = atob(arr[1]),
            n = bstr.length,
            u8arr = new Uint8Array(n);
            while (n--) {
                u8arr[n] = bstr.charCodeAt(n);
            }
            var filename=    this.fileList1[0].file.name;
            let fileData = new FormData();
            fileData.append('pmInsType', 'A');
            fileData.append('pmInsTypePart', '1');       
            fileData.append('files', new File([u8arr], filename+"", {
                    type: mime
                }));
            this.fileList1=[];
            Toast.loading({
                message: '加载中...',
                forbidClick: true,
            });
            djzsUploadProcessFiles(fileData,Object.assign({userName:this.user.userName}))
            .then(res=>{
                Toast.clear();
                if(!res.data){
                    Notify(res.message);
                    return;
                }
                this.file_is_show1=false;
                if(this.fromdetal!=null&&this.fromdetal.fileList!=null){
                    let listdetails = this.fromdetal.fileList;
                    listdetails= listdetails.concat(res.data.data.sysFiles);
                    this.fromdetal.fileList=listdetails;
                    console.log(JSON.stringify(this.fromdetal.fileList))
                }else{
                    if(this.fromdetal==null){
                        this.fromdetal={};
                    }
                    this.fromdetal.fileList=[];
                    this.fromdetal.fileList=res.data.data.sysFiles;
                }
                console.log('XXXX'+JSON.stringify(this.fromdetal.fileList));
                 console.log('XXXX'+this.fromdetal.fileList.length);
                this.file_is_show1=true;
            })
            .catch(err=>{
                 Toast.clear();
                Notify('上传失败');
            })
            // fileList
        },uploadFileDelete1(index){
          this.file_is_show1=false;
          this.fromdetal.fileList.splice(index,1);
          this.file_is_show1=true;
        },
         fileUpload2(file,detail){
            console.log('111'+JSON.stringify(file))
            let dataurl=file.content;
            let arr = dataurl.split(','),
            mime = arr[0].match(/:(.*?);/)[1],
            bstr = atob(arr[1]),
            n = bstr.length,
            u8arr = new Uint8Array(n);
            while (n--) {
                u8arr[n] = bstr.charCodeAt(n);
            }
            var filename=    this.fileList2[0].file.name;
            let fileData = new FormData();
            fileData.append('pmInsType', 'A');
            fileData.append('pmInsTypePart', '1');       
            fileData.append('files', new File([u8arr], filename+"", {
                    type: mime
                }));
            this.fileList1=[];
            Toast.loading({
                message: '加载中...',
                forbidClick: true,
            });
            djzsUploadProcessFiles(fileData,Object.assign({userName:this.user.userName}))
            .then(res=>{
                Toast.clear();
                if(!res.data){
                    Notify(res.message);
                    return;
                }
                this.file_is_show2=false;
                if(this.fromdetal!=null&&this.fromdetal.submitFileList!=null&&this.fromdetal.submitFileList!=[]){
                    let listdetails = this.fromdetal.submitFileList;
                    listdetails= listdetails.concat(res.data.data.sysFiles);
                    this.fromdetal.submitFileList=listdetails;
                    console.log(JSON.stringify(this.fromdetal.submitFileList))
                }else{
                    if(this.fromdetal==null){
                        this.fromdetal={};
                    }
                    this.fromdetal.submitFileList=[];
                    this.fromdetal.submitFileList=res.data.data.sysFiles;
                }
                this.file_is_show2=true;
            })
            .catch(err=>{
                 Toast.clear();
                Notify('上传失败');
            })
            // fileList
        },uploadFileDelete2(index){
          this.file_is_show2=false;
          this.fromdetal.submitFileList.splice(index,1);
          this.file_is_show2=true;
        },
    }
  }
</script>
<style  scoped>
/* @import url();*/
.consume_title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: #fff;
}
.consume_title_left {
  flex: 1;
  font-size: 16px;
  font-weight: 400;
}
.mt10{
     margin-top:10px
 }
.pt50{
     padding-top:60px
}
</style>